<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Dinheiro</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Dinheiro</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/brazilian-rails/lib/dinheiro_rb.html">
                vendor/plugins/brazilian-rails/lib/dinheiro.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h2>Como usar o <a href="Dinheiro.html">Dinheiro</a> em seu <a href="ActiveRecord.html">ActiveRecord</a>?</h2>
<ul>
<li>Arquivo 001_create_lancamentos.rb:

<pre>
  class CreateLancamentos &lt; ActiveRecord::Migration
    def self.up
      create_table :lancamentos do |t|
        t.column :descricao,   :string,    :null =&gt; false
        t.column :valor,       :decimal,   :precision =&gt; 14, :scale =&gt; 2, :null =&gt; false
        t.column :mensalidade, :decimal,   :precision =&gt; 14, :scale =&gt; 2, :null =&gt; false
      end
    end

    def self.down
      drop_table :lancamentos
    end
  end
</pre>
</li>
<li>Arquivo lancamento.rb:

<pre>
  class Lancamento &lt; ActiveRecord::Base
    usar_como_dinheiro :valor, :mensalidade
  end
</pre>
</li>
<li>No console (script/console):

<pre>
  Loading development environment.
  &gt;&gt; lancamento = Lancamento.new
  =&gt; #&lt;Lancamento:0x9652cd8 @attributes={&quot;descricao&quot;=&gt;nil,
                                         &quot;valor&quot;=&gt;#&lt;BigDecimal:9657008,'0.0',4(4)&gt;,
                                         &quot;mensalidade&quot;=&gt;#&lt;BigDecimal:9656e8c,'0.0',4(4)&gt;},
                            @new_record=true&gt;
  &gt;&gt; lancamento.valor = 100
  =&gt; 100
  &gt;&gt; lancamento.valor
  =&gt; #&lt;Dinheiro:0x9650f3c @quantia=10000&gt;
  &gt;&gt; lancamento.valor.real
  =&gt; &quot;R$ 100,00&quot;
  &gt;&gt; lancamento.valor = 100.50
  =&gt; 100.5
  &gt;&gt; lancamento.valor.real
  =&gt; &quot;R$ 100,50&quot;
  &gt;&gt; lancamento.valor = &quot;250.50&quot;
  =&gt; &quot;250.50&quot;
  &gt;&gt; lancamento.valor.real
  =&gt; &quot;R$ 250,50&quot;
  &gt;&gt; lancamento.valor = 354.58.reais
  =&gt; #&lt;Dinheiro:0x9646384 @quantia=35458&gt;
  &gt;&gt; lancamento.valor.real
  =&gt; &quot;R$ 354,58&quot;
  &gt;&gt; exit
</pre>
</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000013">*</a>&nbsp;&nbsp;
      <a href="#M000011">+</a>&nbsp;&nbsp;
      <a href="#M000012">-</a>&nbsp;&nbsp;
      <a href="#M000014">/</a>&nbsp;&nbsp;
      <a href="#M000010">&lt;=&gt;</a>&nbsp;&nbsp;
      <a href="#M000009">==</a>&nbsp;&nbsp;
      <a href="#M000019">coerce</a>&nbsp;&nbsp;
      <a href="#M000024">contabil</a>&nbsp;&nbsp;
      <a href="#M000006">new</a>&nbsp;&nbsp;
      <a href="#M000015">por_extenso</a>&nbsp;&nbsp;
      <a href="#M000016">por_extenso_em_reais</a>&nbsp;&nbsp;
      <a href="#M000022">reais</a>&nbsp;&nbsp;
      <a href="#M000023">reais_contabeis</a>&nbsp;&nbsp;
      <a href="#M000020">real</a>&nbsp;&nbsp;
      <a href="#M000021">real_contabil</a>&nbsp;&nbsp;
      <a href="#M000017">to_extenso</a>&nbsp;&nbsp;
      <a href="#M000018">to_f</a>&nbsp;&nbsp;
      <a href="#M000007">to_s</a>&nbsp;&nbsp;
      <a href="#M000008">to_s_m</a>&nbsp;&nbsp;
      <a href="#M000025">valor_decimal</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->
    <div id="includes">
      <h3 class="section-bar">Included Modules</h3>

      <div id="includes-list">
        <span class="include-name">Comparable</span>
      </div>
    </div>

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">FORMATO_VALIDO_BR</td>
          <td>=</td>
          <td class="context-item-value">/^([R|r]\$\s*)?(([+-]?\d{1,3}(\.?\d{3})*))?(\,\d{0,2})?$/</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">FORMATO_VALIDO_EUA</td>
          <td>=</td>
          <td class="context-item-value">/^([R|r]\$\s*)?(([+-]?\d{1,3}(\,?\d{3})*))?(\.\d{0,2})?$/</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">SEPARADOR_MILHAR</td>
          <td>=</td>
          <td class="context-item-value">&quot;.&quot;</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">SEPARADOR_FRACIONARIO</td>
          <td>=</td>
          <td class="context-item-value">&quot;,&quot;</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">QUANTIDADE_DIGITOS</td>
          <td>=</td>
          <td class="context-item-value">3</td>
        </tr>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">PRECISAO_DECIMAL</td>
          <td>=</td>
          <td class="context-item-value">100</td>
        </tr>
        </table>
      </div>
    </div>



    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">quantia</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(quantia)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 66</span>
66:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">quantia</span>)
67:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">quantia</span> = <span class="ruby-identifier">quantia</span>
68:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000013" class="method-detail">
        <a name="M000013"></a>

        <div class="method-heading">
          <a href="#M000013" class="method-signature">
          <span class="method-name">*</span><span class="method-args">(outro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna a multiplicacao entre dinheiros.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000013-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 116</span>
116:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">*</span>(<span class="ruby-identifier">outro</span>)
117:     <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">to_f</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">outro</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">outro</span>.<span class="ruby-identifier">kind_of?</span> <span class="ruby-constant">Dinheiro</span>
118:     <span class="ruby-identifier">outro</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">to_f</span>
119:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">+</span><span class="method-args">(outro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna a adicao entre dinheiros.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 106</span>
106:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">outro</span>)
107:     <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">transforma_em_string_que_represente_a_quantia</span>(<span class="ruby-ivar">@quantia</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">quantia_de</span>(<span class="ruby-identifier">outro</span>)))
108:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">-</span><span class="method-args">(outro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna a subtracao entre dinheiros.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 111</span>
111:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">outro</span>)
112:     <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">transforma_em_string_que_represente_a_quantia</span>(<span class="ruby-ivar">@quantia</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">quantia_de</span>(<span class="ruby-identifier">outro</span>)))
113:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000014" class="method-detail">
        <a name="M000014"></a>

        <div class="method-heading">
          <a href="#M000014" class="method-signature">
          <span class="method-name">/</span><span class="method-args">(outro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna a divisao entre dinheiros.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000014-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 122</span>
122:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">/</span>(<span class="ruby-identifier">outro</span>)
123:     <span class="ruby-identifier">raise</span> <span class="ruby-constant">DivisaPorNaoEscalarError</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">outro</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Numeric</span>)
124:     <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@quantia</span><span class="ruby-operator">/</span><span class="ruby-identifier">outro</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">outro</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
125:     <span class="ruby-identifier">soma_parcial</span> = <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
126:     <span class="ruby-identifier">parcelas</span> = []
127:     (<span class="ruby-identifier">outro</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>).<span class="ruby-identifier">times</span> <span class="ruby-keyword kw">do</span>
128:       <span class="ruby-identifier">parcela</span> = <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">transforma_em_string_que_represente_a_quantia</span>(<span class="ruby-ivar">@quantia</span><span class="ruby-operator">/</span><span class="ruby-identifier">outro</span>))
129:       <span class="ruby-identifier">parcelas</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">parcela</span>
130:       <span class="ruby-identifier">soma_parcial</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">parcela</span>
131:     <span class="ruby-keyword kw">end</span>
132:     <span class="ruby-identifier">parcelas</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">transforma_em_string_que_represente_a_quantia</span>(<span class="ruby-ivar">@quantia</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">quantia_de</span>(<span class="ruby-identifier">soma_parcial</span>)))
133:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <a href="#M000010" class="method-signature">
          <span class="method-name">&lt;=&gt;</span><span class="method-args">(outro_dinheiro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Compara com outro dinheiro se eh maior ou menor.
</p>
<p>
Exemplo:
</p>
<pre>
 1.real &lt; 2.reais ==&gt; true
 1.real &gt; 2.reais ==&gt; false
 2.real &lt; 1.reais ==&gt; false
 2.real &gt; 1.reais ==&gt; true
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 100</span>
100:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">&lt;=&gt;</span>(<span class="ruby-identifier">outro_dinheiro</span>)
101:     <span class="ruby-identifier">outro_dinheiro</span> = <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">outro_dinheiro</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">outro_dinheiro</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Dinheiro</span>)
102:     <span class="ruby-ivar">@quantia</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">outro_dinheiro</span>.<span class="ruby-identifier">quantia</span>
103:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">==</span><span class="method-args">(outro_dinheiro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Compara com outro dinheiro se eh igual.
</p>
<p>
Exemplo:
</p>
<pre>
 um_real = Dinheiro.new(1)
 um_real == Dinheiro.new(1) ==&gt; true
 um_real == Dinheiro.new(2) ==&gt; false
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 88</span>
88:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">==</span>(<span class="ruby-identifier">outro_dinheiro</span>)
89:     <span class="ruby-identifier">outro_dinheiro</span> = <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">outro_dinheiro</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">outro_dinheiro</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-constant">Dinheiro</span>)
90:     <span class="ruby-ivar">@quantia</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">outro_dinheiro</span>.<span class="ruby-identifier">quantia</span>
91:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000019" class="method-detail">
        <a name="M000019"></a>

        <div class="method-heading">
          <a href="#M000019" class="method-signature">
          <span class="method-name">coerce</span><span class="method-args">(outro)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000019-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 158</span>
158:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">coerce</span>(<span class="ruby-identifier">outro</span>)
159:     [ <span class="ruby-constant">Dinheiro</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">outro</span>), <span class="ruby-keyword kw">self</span> ]
160:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000024" class="method-detail">
        <a name="M000024"></a>

        <div class="method-heading">
          <a href="#M000024" class="method-signature">
          <span class="method-name">contabil</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna uma string formatada.
</p>
<p>
Exemplo:
</p>
<pre>
 Dinheiro.new(1).contabil ==&gt; '1,00'
 Dinheiro.new(-1).contabil ==&gt; '(1,00)'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000024-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 191</span>
191:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">contabil</span>
192:     <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@quantia</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-value">0</span>
193:       <span class="ruby-identifier">to_s</span>      
194:     <span class="ruby-keyword kw">else</span>  
195:       <span class="ruby-value str">&quot;(&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">to_s</span>[<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;)&quot;</span>    
196:     <span class="ruby-keyword kw">end</span>  
197:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000015" class="method-detail">
        <a name="M000015"></a>

        <div class="method-heading">
          <a href="#M000015" class="method-signature">
          <span class="method-name">por_extenso</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Escreve o valor por extenso.
</p>
<p>
Exemplo:
</p>
<pre>
 1.real.por_extenso ==&gt; 'um real'
 (100.58).por_extenso ==&gt; 'cem reais e cinquenta e oito centavos'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000015-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 140</span>
140:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">por_extenso</span>
141:     (<span class="ruby-ivar">@quantia</span><span class="ruby-operator">/</span><span class="ruby-value">100.0</span>).<span class="ruby-identifier">por_extenso_em_reais</span>
142:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000016" class="method-detail">
        <a name="M000016"></a>

        <div class="method-heading">
          <span class="method-name">por_extenso_em_reais</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Dinheiro.html#M000015">por_extenso</a>
</p>
        </div>
      </div>

      <div id="method-M000022" class="method-detail">
        <a name="M000022"></a>

        <div class="method-heading">
          <span class="method-name">reais</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Dinheiro.html#M000020">real</a>
</p>
        </div>
      </div>

      <div id="method-M000023" class="method-detail">
        <a name="M000023"></a>

        <div class="method-heading">
          <span class="method-name">reais_contabeis</span><span class="method-args">()</span>
        </div>
      
        <div class="method-description">
          <p>
Alias for <a href="Dinheiro.html#M000021">real_contabil</a>
</p>
        </div>
      </div>

      <div id="method-M000020" class="method-detail">
        <a name="M000020"></a>

        <div class="method-heading">
          <a href="#M000020" class="method-signature">
          <span class="method-name">real</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna uma string formatada em valor monetario.
</p>
<p>
Exemplo:
</p>
<pre>
 Dinheiro.new(1).real ==&gt; 'R$ 1,00'
 Dinheiro.new(-1).real ==&gt; 'R$ -1,00'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000020-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 167</span>
167:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">real</span>
168:     <span class="ruby-value str">&quot;R$ &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">to_s</span>
169:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000021" class="method-detail">
        <a name="M000021"></a>

        <div class="method-heading">
          <a href="#M000021" class="method-signature">
          <span class="method-name">real_contabil</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna uma string formatada em valor monetario.
</p>
<p>
Exemplo:
</p>
<pre>
 Dinheiro.new(1).real ==&gt; 'R$ 1,00'
 Dinheiro.new(-1).real ==&gt; 'R$ (1,00)'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000021-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 176</span>
176:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">real_contabil</span>
177:     <span class="ruby-value str">&quot;R$ &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">contabil</span>
178:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000017" class="method-detail">
        <a name="M000017"></a>

        <div class="method-heading">
          <a href="#M000017" class="method-signature">
          <span class="method-name">to_extenso</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
DEPRECATION WARNING: use <a href="Dinheiro.html#M000015">por_extenso</a> ou
<a href="Dinheiro.html#M000016">por_extenso_em_reais</a>, pois este sera
removido no proximo release.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000017-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 148</span>
148:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_extenso</span>
149:     <span class="ruby-identifier">warn</span>(<span class="ruby-value str">&quot;DEPRECATION WARNING: use por_extenso ou por_extenso_em_reais, pois este sera removido no proximo release.&quot;</span>)
150:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">por_extenso</span>
151:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000018" class="method-detail">
        <a name="M000018"></a>

        <div class="method-heading">
          <a href="#M000018" class="method-signature">
          <span class="method-name">to_f</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna um Float.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000018-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 154</span>
154:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_f</span>
155:     <span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'.'</span>, <span class="ruby-value str">''</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">','</span>, <span class="ruby-value str">'.'</span>).<span class="ruby-identifier">to_f</span>
156:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000007" class="method-detail">
        <a name="M000007"></a>

        <div class="method-heading">
          <a href="#M000007" class="method-signature">
          <span class="method-name">to_s</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna o valor armazenado em string.
</p>
<p>
Exemplo:
</p>
<pre>
 1000.to_s ==&gt; '1.000,00'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000007-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 74</span>
74:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
75:     <span class="ruby-identifier">inteiro_com_milhar</span>(<span class="ruby-identifier">parte_inteira</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">parte_decimal</span>
76:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000008" class="method-detail">
        <a name="M000008"></a>

        <div class="method-heading">
          <a href="#M000008" class="method-signature">
          <span class="method-name">to_s_m</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000008-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 78</span>
78:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s_m</span>
79:     <span class="ruby-identifier">inteiro_com_milhar</span>(<span class="ruby-identifier">parte_inteira</span>)
80:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000025" class="method-detail">
        <a name="M000025"></a>

        <div class="method-heading">
          <a href="#M000025" class="method-signature">
          <span class="method-name">valor_decimal</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Retorna um BigDecinal.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000025-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/brazilian-rails/lib/dinheiro.rb, line 200</span>
200:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valor_decimal</span>
201:     <span class="ruby-constant">BigDecimal</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">quantia_sem_separacao_milhares</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">','</span>,<span class="ruby-value str">'.'</span>)
202:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>